﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace Pow
{
    class HUD
    {
        Game1 game;
        Texture2D lifeSprite;
        public int life;
        SpriteFont font;
        public string score;
        Vector2 posicaoScore;

        private int totalLives = 10;

        public HUD(Game1 game)
        {
            this.game = game;
            loadContent();
        }

        private void loadContent()
        {
            lifeSprite = game.Content.Load<Texture2D>("BarraDeVida");
            font = game.Content.Load<SpriteFont>("SpriteFont2");
            posicaoScore = new Vector2(10, 10);
        }

        public void update(GameTime gameTime, Jogador jogador)
        {
            life = jogador.life;
            score = ("" + jogador.score.ToString("00000"));
 
        }

        public void drawLifeBar(GameTime gameTime)
        {
            game.spriteBatch.DrawString(font, score, posicaoScore, Color.White);
            
            for (var i = 0; i < totalLives; i++)
            {
                int inicial = 600;
                int espaco = 3;
                Vector2 fullLifePositionOnScreen = new Vector2(inicial + i * (espaco + 14),10);
                //Console.WriteLine("Life = " + life);
                if (i < life)
                {
                    game.spriteBatch.Draw(lifeSprite, fullLifePositionOnScreen, new Rectangle(0, 0, 14, 61), Color.White);
                }
                else
                {
                    game.spriteBatch.Draw(lifeSprite, fullLifePositionOnScreen, new Rectangle(28, 0, 14, 61), Color.White);
                }
 
            }



        }

    }
}
